//
//  YDVerticalDetailNewsCell.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/1/7.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDVerticalDetailNewsCell.h"
#import "YDSingleStockNewsModel.h"


@interface YDVerticalDetailNewsCell()
//分割线
@property (nonatomic , weak) UIView *lineView;

@property (nonatomic , weak) UILabel *titleLabel;
@property (nonatomic , weak) UILabel *timeLabel;


@end

@implementation YDVerticalDetailNewsCell

-(void)setModel:(YDSingleStockNewsModel *)model
{
    _model = model;
    self.titleLabel.text = model.title;
    
    self.timeLabel.text = model.timeString;
    
    self.titleLabel.frame = model.titleFrame;
    self.timeLabel.frame = model.timeFrame;
    
    
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *verticalDetailNewsCell = @"YDVerticalDetailNewsCell";
    YDVerticalDetailNewsCell *cell = [tableView dequeueReusableCellWithIdentifier:verticalDetailNewsCell];
    if (cell == nil) {
        cell = [[YDVerticalDetailNewsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:verticalDetailNewsCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.backgroundColor = [UIColor whiteColor];
        [self lineView];
        [self titleLabel];
        [self timeLabel];
        
    }
    return self;
}

-(UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        UILabel *titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:titleLabel];
        titleLabel.textColor = [UIColor colorWithHexString:dark];
        titleLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        titleLabel.textAlignment = NSTextAlignmentLeft;
        titleLabel.numberOfLines = 0;
        titleLabel.text = @"标题";
        _titleLabel = titleLabel;
    }
    return _titleLabel;
}

-(UILabel *)timeLabel
{
    if (_timeLabel == nil) {
        UILabel *timeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:timeLabel];
        timeLabel.textColor = [UIColor colorWithHexString:blueyGrey];
        timeLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        timeLabel.textAlignment = NSTextAlignmentLeft;
        timeLabel.numberOfLines = 1;
        timeLabel.text = @"时间";
        _timeLabel = timeLabel;
    }
    return _timeLabel;
}

-(UIView *)lineView
{
    if (_lineView == nil) {
        UIView *lineView = [[UIView alloc] init];
        [self.contentView addSubview:lineView];
        lineView.backgroundColor = [UIColor colorWithHexString:mainGray];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self);
            make.height.equalTo(@1);
        }];
        _lineView = lineView;
    }
    return _lineView;
}

@end
